/**
 * @Author: 17197
 * @Date: 2024-05-03 23:11:06
 * @Description: request.ts
 * @Version: 1.0
 * @Last Modified time : 2024-05-03 23:11:06
 **/
import axios from 'axios'

const service = axios.create({
	baseURL: 'http://localhost:8101/api/',
	timeout: 5000
})

service.interceptors.response.use(
	(response) => {
		const res = response.data
		if (res.code !== 0) {
			console.log(res.msg)
			return Promise.reject(new Error(res.msg || 'Error')) // 返回错误信息
		} else {
			return res.data
		}
	},
	(error) => {
		console.log('err' + error)
		return Promise.reject(error)
	}
)

export default service
